import { defineStore } from "pinia";
import { ref } from "vue";
// import { v4 as uuidv4 } from "uuid";

const storeSetup = () => {
  // 数据
  // 审核人id
  const auditUserIds = ref([32, 145]);

  // 预约人id
  const appointmentUserIds = ref([135]);

  // 当前用户身份  0 预约人   1 审核人
  const currentUserIdentity = ref(0);

  // 判断是提交人还是审核人
  const judgeIdentity = id => {
    // let userInfo = JSON.parse(localStorage.getItem("geeker-user"));
    // let userId = userInfo.userInfo.id;
    if (auditUserIds.value.includes(id)) {
      currentUserIdentity.value = 1;
    } else if (appointmentUserIds.value.includes(id)) {
      currentUserIdentity.value = 0;
    }
  };

  // 返回参数
  return {
    auditUserIds,
    appointmentUserIds,
    currentUserIdentity,
    judgeIdentity
  };
};

// 导出Store
export const useAppointmentStore = defineStore("appointment", storeSetup);
